from utils.time_util import YYYYMMDDHHMMSS, fmt_d
from utils.file_utils import write, append_write
from constant.param_config import getLogPath, getLogeFilePath
import os


def saveLog(msg):
    """
    保存日志
    """
    logFile = getLogeFilePath()
    result = getMessage(msg) + "\n"

    if not os.path.exists(logFile):
        write(logFile, result, "w")
    else:
        append_write(logFile, result)


def prints(msg, br=""):
    try:
        result = getMessage(msg)
        print(br + result)
    except Exception as e:
        print("" + str(e))


def getMessage(msg):
    current_time = fmt_d(fmt_str=YYYYMMDDHHMMSS)
    result = str(current_time) + " :::::: " + str(msg)
    return result
